package com.atguigu.gulimall.search.web;

import com.atguigu.gulimall.search.service.MallSearchService;
import com.atguigu.gulimall.search.vo.SearchReqVO;
import com.atguigu.gulimall.search.vo.SearchRespVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

import javax.servlet.http.HttpServletRequest;

/**
 * @author DuGuanghan
 * @since 2024-05-31 17:28:07
 */
@Controller
public class SearchController {

    @Autowired
    MallSearchService mallSearchService;

    @GetMapping("/list.html")
    public String list(SearchReqVO searchReqVO, Model model, HttpServletRequest req) {
        req.getQueryString();

        SearchRespVO result = mallSearchService.search(searchReqVO);
        model.addAttribute("result", result);

        return "list";
    }

}
